import { calc } from 'a-calc/es';
import {huantai} from "@/static/mock/huantai";

export default {
  data() {
    return{
      huantaiList: huantai,
      huantaiSelectShow: false,

      hltSubtotal: '',
      form:{
        hlt2Down: '',
        hlt2Up: '',
        hltCount: '',
        hltChargingStandard: '',
        hltIsUp: '',
        hltSubtotal: 0,
      }
    }
  },
  watch:{

    // 换轮胎 - 收费标准
    'form.hltChargingStandard'(){
      this.getHuanLunTaiFei()
    },
    // 换轮胎 - 数量
    'form.hltCount'(){
      this.getHuanLunTaiFei()
    },
    // 换轮胎 - 上浮
    'form.hltIsUp'(){
      this.getHuanLunTaiFei()
    },
  },
  methods: {
    getHuanLunTaiFei() {
      const count = this.form.hltCount * 1;
      let leiji = 0;
      let base = 0;
      if(!count){
        this.hltSubtotal = '';
      }else{
        if( count === 1){
          base = Number(this.form.hltChargingStandard);
        } else if(count >= 2){
          base = Number(this.form.hltChargingStandard);
          leiji = (count - 1) * 50
        }
        this.hltSubtotal = calc(`
				(${base || 0} + ${leiji} ) * (${this.form.hltIsUp === '是'?1.2:1})
			`)
      }
    },
    // 换胎
    huantaiConfirm(val) {
      const obj = huantai[val[0].value];
      this.form.hltChargingStandard = obj.basis;
      this.form.hlt2DownOrhlt2Up = obj.label;
      if(obj.basis === 200){
        this.form.hlt2Down = '√'
        this.form.hlt2Up = ''
      }else{
        this.form.hlt2Down = ''
        this.form.hlt2Up = '√'
      }

      this.form.hltIsUp = '否'
    },
	sethltType(){
		if(this.form.hlt2Down === '√'){
			this.form.hlt2DownOrhlt2Up = "2吨(含)以下"
		}
		if(this.form.hlt2Up === '√'){
			this.form.hlt2DownOrhlt2Up = "2吨以上"
		}
	},
	huantaiCancel(){
		if(!+this.hltSubtotal){
			this.form.hlt2DownOrhlt2Up = ""
			this.form.hlt2Down = ""
			this.form.hlt2Up = ""
			this.form.hltIsUp = ""
			this.form.hltCount = ""
			this.form.hltChargingStandard = ""
		}
	}
  },
}
